<?php
/**
 * Notes:
 * User: wudg <544038230@qq.com>
 * Date: 2025/7/3 14:08
 */

namespace App\Dao\Users;


use App\Dao\BaseDao;
use App\Model\Users\User;
use Hyperf\Database\Concerns\BuildsQueries;
use Hyperf\Database\Model\Builder;
use Hyperf\Database\Model\Model;

class UsersDao extends BaseDao
{
    /**
     * 通过账号获取用户表信息
     * @param string $account
     * @return User|BuildsQueries|Builder|Model|object|null
     */
    public function getInfoByAccount(string $account,array $with = [])
    {
        $model = empty($with) ? User::query() : User::with($with);
        return $model->where('account','=',$account)->first();
    }

    /**
     * 通过主键获取用户详细信息
     * @param int $uid
     * @return User|BuildsQueries|Builder|Model|object|null
     */
    public function getInfoByPk(int $uid)
    {
        return User::query()->where('id','=',$uid)->first();
    }


    /**
     * 按手机号获取用户信息
     * @param string $phone
     * @return User|BuildsQueries|Builder|Model|object|null
     */
    public function getInfoByPhone(string $phone)
    {
        return User::query()->where('phone','=',$phone)->first();
    }
}